package com.chanyachting.emall.domain;

import java.lang.reflect.InvocationTargetException;
import java.util.List;

import org.apache.commons.beanutils.BeanUtils;

import com.chanyachting.emall.dao.BusinesscategoryDAO;
import com.chanyachting.emall.domain.base.BaseBusinesscategory;

/**
 * This is the object class that relates to the businesscategory table.
 * Any customizations belong here.
 */
public class Businesscategory extends BaseBusinesscategory {

/*[CONSTRUCTOR MARKER BEGIN]*/
	public Businesscategory () {
		super();
	}

	/**
	 * Constructor for primary key
	 */
	public Businesscategory (java.lang.Integer _id) {
		super(_id);
		
		Businesscategory bcategory=(Businesscategory)new BusinesscategoryDAO().load(Businesscategory.class, _id);
		
		if(bcategory!=null){
			
			try {
				BeanUtils.copyProperties(this, bcategory);
			} catch (IllegalAccessException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			} catch (InvocationTargetException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
		}
	}

	/**
	 * Constructor for required fields
	 */
	public Businesscategory (
		java.lang.Integer _id,
		java.lang.Integer _businessTypeId) {

		super (
			_id,
			_businessTypeId);
	}

/*[CONSTRUCTOR MARKER END]*/
	
	public static List list(){
	
		return new BusinesscategoryDAO().find("from Businesscategory");
	}
	
	
	public static List listByBusinessTypeId(int businessTypeId){
		
		String args[]={String.valueOf(businessTypeId)};
		
		return new BusinesscategoryDAO().find("from Businesscategory where businessTypeId=?",args);
	}
	
	
	
}